package com.liqy.huoshan.model.home;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.liqy.huoshan.R;
import com.liqy.huoshan.common.BaseFragment;

import butterknife.BindView;
import butterknife.ButterKnife;


public class HomeLiveFragment extends BaseFragment implements HomeLiveContract.View {

    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";
    public HomeLiveContract.Presenter presenter;
    private String mParam1;
    private String mParam2;

    @BindView(R.id.helloTitle)
    TextView helloTitle;

    public HomeLiveFragment() {
        // Required empty public constructor
    }


    public static HomeLiveFragment newInstance(String param1, String param2) {
        HomeLiveFragment fragment = new HomeLiveFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
        presenter = new HomeLivePresenter(this);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_home_live, container, false);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        presenter.subscribe();
    }

    @Override
    public void showTitle() {
        helloTitle.setText(presenter.getTitle());
        //TODO 展示视图
    }

    @Override
    public void setPresenter(HomeLiveContract.Presenter presenter) {

        this.presenter = presenter;
    }

    @Override
    public void login() {

    }

    @Override
    public void showError() {

    }
}
